package com.ctbri.manage.quality;
import org.apache.hive.jdbc.HiveStatement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.*;

public class DataMaker {


    static final Logger log = LoggerFactory.getLogger(DataMaker.class);
    static final String driverName = "org.apache.hive.jdbc.HiveDriver";
    static final String url = "jdbc:hive2://172.16.1.160:10000";
    static final String dbName = "mdm";
   // static Connection con = null;
    static Statement state = null;
    static ResultSet res = null;

    public static void init() {
       /* try {
            Class.forName(driverName);
//            DataMaker.con = DriverManager.getConnection(DataMaker.url + "/" + DataMaker.dbName, "hadoop", "");
//            DataMaker.state = DataMaker.con.createStatement();
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }*/

    }
    public void loadPartitionData(final String tableName) throws SQLException {
        init();
        state.execute("insert into table " + tableName +
                " select * from tempHiveTest");
    }

    public static void main(String[] args) throws ClassNotFoundException, SQLException, InterruptedException{
        DataMaker.init();
        DataMaker dataMaker = new DataMaker();
        final int cishu = 500;
//        for (int i=0; i<cishu; ++i){
//            if (i % 50 == 0) System.out.println(i);
//            dataMaker.loadPartitionData("tempHiveTest5w");
//        }
    }
}
